import { defHttp } from '/@/utils/http/axios';
import { PageResult } from '@/api/model/pageResult';
import { ContentTypeEnum } from '@/enums/httpEnum';
import { QueryMarketingFulldiscountBo } from '@/api/promotions/fulldiscount/model/queryMarketingFulldiscountBo';
import { QueryMarketingFulldiscountVo } from '@/api/promotions/fulldiscount/model/queryMarketingFulldiscountVo';
import { GetMarketingFulldiscountBo } from '@/api/promotions/fulldiscount/model/getMarketingFulldiscountBo';
import { CreateMarketingFulldiscountVo } from '@/api/promotions/fulldiscount/model/createMarketingFulldiscountVo';
import { UpdateMarketingFulldiscountVo } from '@/api/promotions/fulldiscount/model/updateMarketingFulldiscountVo';

const baseUrl = '/promo/fulldiscount';
const region = 'cloud-api';

/**
 * 查询列表
 * @param params
 * @returns {Promise}
 */
export function query(
  params: QueryMarketingFulldiscountVo,
): Promise<PageResult<QueryMarketingFulldiscountBo>> {
  return defHttp.get<PageResult<QueryMarketingFulldiscountBo>>(
    {
      url: baseUrl + '/query',
      params: params,
    },
    {
      region,
    },
  );
}

/**
 * 根据ID查询
 * @param id
 * @returns {Promise}
 */
export function get(id: String): Promise<GetMarketingFulldiscountBo> {
  return defHttp.get<GetMarketingFulldiscountBo>(
    {
      url: baseUrl,
      params: {
        id,
      },
    },
    {
      region,
    },
  );
}

/**
 * 新增
 * @param params
 * @returns {Promise}
 */
export function create(params: CreateMarketingFulldiscountVo): Promise<void> {
  return defHttp.post<void>(
    {
      url: baseUrl,
      data: params,
    },
    {
      contentType: ContentTypeEnum.JSON,
      region,
    },
  );
}

/**
 * 修改
 * @param params
 * @returns {Promise}
 */
export function update(params: UpdateMarketingFulldiscountVo): Promise<void> {
  return defHttp.put<void>(
    {
      url: baseUrl,
      data: params,
    },
    {
      contentType: ContentTypeEnum.JSON,
      region,
    },
  );
}
